package com.cskaoyan.market.controller.wx;

import com.cskaoyan.market.annotation.ValidParam;
import com.cskaoyan.market.bo.FeedBackBo;
import com.cskaoyan.market.service.wx.WxFeedBackService;
import com.cskaoyan.market.util.ResponseUtil;
import com.cskaoyan.market.util.ValidationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author: YaLiFeng
 * @description: TODO
 * @date: 2024/5/20 22:16
 */
@RestController
@RequestMapping("/wx/feedback")
public class WxFeedBackController {
    @Autowired
    WxFeedBackService wxFeedBackService;
    @PostMapping("submit")
    @ValidParam
    public Object submit(@Valid @RequestBody FeedBackBo feedBackBo, BindingResult bindingResult){
        Object object=ValidationUtil.validate(bindingResult);
        if(object!=null){
            return ResponseUtil.fail(401,"参数不对");
        }
        int res=wxFeedBackService.feedback(feedBackBo);
        if(res==-1){
            return ResponseUtil.fail(401,"用户未登录");
        }
       return ResponseUtil.ok();
    }
}
